home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / mslang / stepon / _temp302.sc_ / _temp302.sc
Encoding:
Text File  |  1994-04-30  |  14.1 KB  |  360 lines

  1. '                   ^^^^^^^^^^
  2. '              This program is configured in table part: Choose radio button Table
  3. '
  4. ' Hint:
  5. ' You're allowed to use this script or parts of changed or unchanged in your StepOne
  6. ' installation. 
  7. ' This script features professional installations for Windows and is full of hints and
  8. ' examples for your work with StepOne.
  9. ' If you change the table part (view: Table) of the script to your needs,
  10. ' you have a very good installation.
  11. ' One of the highlights of StepOne is the possibility to improve this installation script with 
  12. ' the powerful script language, so you have full control of the whole installation process.
  13. ' If you start this program without making changes, a new path will be created.
  14. ' If you edit the tables of the Table part corresponding to your needs you get a full installation.
  15.  
  16. ' If you start this script within StepIt, the StepOne FastCodeBuilder, you have to set the path
  17. ' of the to be copied files with menue FASTCODE - SETTINGS - COMMANDLINE, i.e. 'a:'.
  18. ' If the path is followed with a space and -1, you're abled to get the information that
  19. ' StepOne was started within StepIt.
  20. ' ***************************************************************************************************
  21.  
  22. ' ***************************************************************************************************
  23. ' The command line (View: FastCode - Settings - Commandline)which StepIt.exe or Install.exe (FirstStep) 
  24. ' passes through is saved in a variable.
  25. Len "ln", "{_command}"
  26. If "{ln}" = "0"
  27.     Label "NoSourcePath"
  28.     PathBox "command", "Please choose the path of the to be installed files.", "Choose source path", "{_bootdrv}\", "", "", "0", "&OK"
  29. Else
  30.     Let "command", "{_command}"
  31. EndIf
  32. DirExist "res", "{command}"
  33. If "{res}" = "0"
  34.     Goto "NoSourcePath"
  35. EndIf
  36.  
  37. Split "sourcepath",    "{command}","32","1"
  38. Split "StepIt",        "{command}","32","2"
  39.  
  40. Let "prgname", "{prginfos[1;1]}"
  41. Let "mainprg", "{prginfos[2;1]}"
  42.  
  43. ' Look if program runs
  44. GoSub "CheckPrg","{mainprg}"
  45. ' Welcome the user and give hints of using the installation
  46. GoSub "Welcome"
  47. ' Checking VBX files if they are loaded or installed in the Windows directory
  48. GoSub "CheckLibraries"    
  49.  
  50. Label "copyloop"
  51. ' The user can choose the installation path
  52. GoSub "GetTargetPath",  "{prginfos[3;1]}"
  53. ' Create the choosen path
  54. GoSub "CreatePath"
  55. If "{path}" = "0"
  56.     ' If create operation fails or user choosed anything other
  57.     Goto "CopyLoop"
  58. EndIf
  59.  
  60. ' Install files
  61. GoSub "Copying"
  62. If "{space}" = "-1"
  63.     ' Copying failed because of unsufficient disk space.
  64.     ' User has to choose another drive.
  65.     Goto "CopyLoop"
  66. EndIf
  67.  
  68. ' Add icon(s) in Program Manager group
  69. GoSub "ProgMan"
  70.  
  71. ' Add Extension(s)in Registration Database
  72. GoSub "RegBase"
  73.  
  74. ' Edit program INI file(s)
  75. GoSub "PrgINIs"
  76. If "{prginfos[4;1]}" = "-1"
  77.     GoSub "ShareExe"
  78. EndIf
  79.  
  80. ' Inform user about end of installation.
  81. ' Name of program is passed through to give user the possibility to start program immediately.
  82. GoSub "PrgEnd"
  83. ' End of installation
  84. End
  85.  
  86. ' *************************************************************
  87. Sub "Welcome"
  88.     ' Show main window
  89.     Window "-1", "{prgname} Installation", "Welcome", "Welcome to installation of {prgname}. Installation program will lead you through all neccessary steps.{_nl}{_nl}Press Continue to start installation.{_nl}{_nl}Press keys Ctrl and C together to cancel installation.", "", "43;23;960;888", "9"
  90.      GetUserInput "&Continue"
  91. EndSub
  92.  
  93. ' ***************************************************************************************************
  94. Sub "GetTargetPath"
  95.     Parameter targetpath    
  96.     Window "-1", "", "Choose target path", "Please select the path where {prgname} should be installed to."
  97.     Label "GetTargetPath1"
  98.     ' If {ret} is a complete path, 'pathbox' uses only the part after the last backslash.
  99.     ' In example 'c:\windows\system' will be used from 'PathBox' paramter 'Additional Path' as 'system'.
  100.     ' PathBox parameter DefaultPath can contain a relative path, i.e.: 'c:\windows\..' get to 'c:\'.
  101.     PathBox "targetpath", "Please choose the path for {prgname}.", "", "{_windowsdir}\..", "{GetTargetPath:targetpath}", "", "0", "&OK;&Cancel"
  102.     If "{targetpath}" = ""
  103.         ' User has choosed 'Cancel'. AskEnd asks the user if he want to end the program.
  104.         'If user chooses 'Yes', AskEnd works like End.
  105.         AskEnd
  106.         Goto "GetTargetPath1"    
  107.     EndIf
  108. EndSub
  109. ' ***************************************************************************************************
  110. ' New VBX and DLL files can be installed if they aren't loaded.
  111. Sub "CheckLibraries"
  112.     ' If installation program is started within StepIt, check for libraries
  113.     ' isn't neccessary. StepIt uses 
  114.     ' cscombo.vbx, csdialog.vbx, csform.vbx, ss3d.vbx, ss3d2.vbx, qpro200.dll
  115.     ' Some installation programs would fail at this point.
  116.     ' If you don't use the libraries you should set the if selection as remark.
  117.     If "{StepIt}" <> "-1"
  118.         ' Gets number of elements
  119.         GetTableElementCount "number_vbx", "vbxtable"
  120.         For "i", "1", "{number_vbx}"
  121.             FileExist "wfound", "{_windowsdir}\{vbxtable[1;i]}"
  122.              If "{wfound}" = "-1"
  123.                 GoSub "CorrectVBX", "{i}"
  124.             EndIf
  125.         Next
  126.     EndIf
  127. EndSub
  128. ' *********************************************************************************************
  129. Sub "CorrectVBX"
  130.     Parameter "iVbx"
  131.     Label "Active"
  132.     'Copies a common used file    from windows to system directory to force version control
  133.     'It isn't checked if any of the common used files are installed anywhere on the users
  134.     'system. So, nevertheless version conflicts may occure. But this procedure
  135.     'fixed the common mistake to install vbx and dll in the windows directory.
  136.     IsTaskActive "res", "{vbxtable[1;i]}"
  137.     If "{res}" = "-1"
  138.         MsgBox "res", "'{vbxtable[1;i]}' is in use. Please exit the application which uses the file and try it again.{_NL}If you aren't sure which application uses the library please exit all applications except of the Program Manager and this program.", "", "&Retry;&Program End"
  139.         If "{res}" = "2"
  140.             GoSub CloseAll
  141.             End
  142.         Else
  143.             Goto "Active"
  144.         EndIf
  145.     Else
  146.         MsgBox "correct", "'{vbxtable[1;i]}' was found in your Windows directory. {_nl}Libraries like '{vbxtable[1;i]}' should be installed in System directory.{_nl}Should installation program '{vbxtable[1;i]}' correct the problem? To be sure that '{prgname}' runs correctly you should choose 'Correct'!", "", "&Correct;&Ignore"
  147.          If "{correct}" = "1"
  148.             Copy "{_windowsdir}\{vbxtable[1;i]}", "{_systemdir}\{vbxtable[1;i]}", "2" 
  149.             If "{_err}" = "0"
  150.                 Del "{_windowsdir}\{vbxtable[1;i]}"
  151.             Else
  152.                 OutBox "'{vbxtable[1;i]}' couldn't be moved to System directory. If '{prgname}' doesn't run you should repeat the installation."
  153.             EndIf
  154.         EndIf
  155.       EndIf
  156. EndSub
  157.  
  158. ' ***************************************************************************************************
  159. Sub "CheckPrg"
  160.     Parameter "p"
  161.     Label "CheckPrg2"
  162.     IsTaskActive "res","{CheckPrg:p}"
  163.     If "{res}" = "-1"
  164.         MsgBox "ret", "{CheckPrg:p} is active. To install a newer version you have to close it first, to be sure that version control works correct. Should installation program close {PrⁿfePrg:p} for you?", "", "&Task close;&Retry;&Program end"
  165.         If "{ret}" = "1"
  166.             TaskStop "{CheckPrg:p}"
  167.         EndIf
  168.         If "{ret}" = "3"
  169.             End
  170.         EndIf
  171.         Goto "CheckPrg2"
  172.     Else
  173.         Goto "CheckPrg1"
  174.     EndIf
  175. Label "CheckPrg1"
  176. EndSub
  177.  
  178. ' ***************************************************************************************************
  179. Sub "CreatePath"
  180.     DirExist "res", "{targetpath}"
  181.     If "{res}" = "0"
  182.         MsgBox "res", "'{targetpath}' doesn't exist.{_nl}Do you want to create the path?", "", "&Create;Change &selection;&Program end"
  183.         If "{res}" = "3"
  184.             End
  185.         EndIf
  186.         If "{res}" = "2"
  187.             Let "directory", "0"    
  188.             Goto "CreatePath1"    
  189.         EndIf
  190.         MkDir "{targetpath}"
  191.         If "{_err}" = "-1"
  192.             OutBox "During creation of path '{targetpath}' an error occurs. Please choose another path."
  193.             Let "directory", "0"        
  194.         Else
  195.             Let "directory", "-1"
  196.         EndIf
  197.     Else
  198.         Let "directory", "-1"
  199.     EndIf
  200. Label "CreatePath1"
  201. EndSub
  202.  
  203. ' ***************************************************************************************************
  204. Sub "Copying"
  205.     Window "-1", "", "Copying...", " "
  206.     SplitPathName "todrv", "{targetpath}", "5"
  207.     ' StepOne calcs the total of all file lengths and substracts the sum of
  208.     ' the file lengths which will be overwritten. The minimum isn't 0
  209.     ' indeed it is the length of the longest file, which should be installed
  210.     ' if the installation is on the same drive as temp drive.
  211.     CalcFileTable "targetbytes", "targettable", "{sourcepath}", "{targetpath}", "3"
  212.     CalcFileTable "systembytes", "systemtable", "{sourcepath}", "{_systemdir}", "3"
  213.     ' Checks if two given paths have the same drive name
  214.     If "{_systemdir}" := "{targetpath}"
  215.         Compute "tofreebytes","{tofreebytes}" + "{targetbytes}"
  216.     Else
  217.         GetDiskFree "systemfreebytes", "{_systemdir}"    
  218.         If "{systembytes}" > "{systemfreebytes}"
  219.             OutBox "On drive{_nl}'{todrv}'{_nl}isn't enough space free. {systembytes} bytes free space required.{_nl}Please free enough space on drive and retry installation."
  220.             End
  221.         EndIf
  222.     EndIf
  223.     GetDiskFree "tofreebytes", "{targetpath}"
  224.     If "{targetbytes}" > "{tofreebytes}"
  225.         OutBox "On drive{_nl}'{todrv}'{_nl}isn't enough space free. Please choose another drive."
  226.         Let "space", "-1"
  227.         Goto "Copying_end"
  228.     Else
  229.         Window "-1", "", "Copying...", "Please be patient..."
  230.         GetTableLineCount "number_copy", "targettable"
  231.         If "{number_copy}" > "0"
  232.             CopyFileTable "targettable", "{sourcepath}", "{targetpath}", "1", "0"
  233.             If "{_err}" = "-1"
  234.                 MsgBox "res", "During copying occurs errors. Do you want to continue installation nevertheless?", "", "&OK;&Program end"
  235.                 If "{res}" = "2"
  236.                     End
  237.                 EndIf
  238.             EndIf
  239.         EndIf
  240.         If "{StepIt}" <> "-1"
  241.             GetTableLineCount "number_copy", "systemtable"
  242.             If "{number_copy}" > "0"
  243.                 Window "-1", "", "Copying system files..."
  244.                 CopyFileTable "systemtable", "{sourcepath}", "{_systemdir}", "1", "0"
  245.                 'Make sure, dialog will be closed
  246.                 CopyFileTable
  247.                 If "{_err}" = "-1"
  248.                     MsgBox "res", "During copying occurs errors. Do you want to continue installation nevertheless?", "", "&OK;&Program end"
  249.                     If "{res}" = "2"
  250.                         End
  251.                     EndIf
  252.                 EndIf
  253.             EndIf
  254.         EndIf
  255.         Let "space", "0"    
  256.     EndIf
  257.     Label "copying_end"
  258. EndSub
  259.  
  260. ' ***************************************************************************************************
  261. Sub "ProgMan"
  262.     ' Get number of elements
  263.     GetTableLineCount "number_prg", "prgmantable"
  264.     If "{number_prg}" > "0"
  265.         Window "-1", "", "Installing icons...", "Please be patient..."
  266.         Let "i", "1"
  267.         Let "tmp",""
  268.         Label "ProgMan1"    
  269.         If "{tmp}" <>  "{prgmantable[i;1]}"
  270.             Let "tmp", "{prgmantable[i;1]}"
  271.             DDEExecute "ProgMan", "ProgMan", "", "[creategroup({prgmantable[i;1]})]"
  272.             If "{_err}" = "-1"
  273.                 OutBox "Group '{prgmantable[i;1]}' couldn't be created in Program Manager."
  274.             EndIf
  275.         EndIf
  276.         GoSub "icon","{prgmantable[i;1]}","{targetpath}\{prgmantable[i;2]}","{prgmantable[i;3]}"
  277.         Compute "i", "{i}" + "1"
  278.         If "{i}" <= "{number_prg}"
  279.             Goto "ProgMan1"
  280.         EndIf
  281.     EndIf
  282. EndSub
  283.  
  284. ' ***************************************************************************************************
  285. Sub "Icon"
  286. Parameter "group","name","title"
  287.     ' Sets the group window so that 'replaceitem' can find the group window
  288.     DDEExecute "ProgMan", "ProgMan", "", "[showgroup({icon:group},1)]"
  289.     DDEExecute "ProgMan", "ProgMan", "", "[showgroup({icon:group},2)]"
  290.     ' Deletes icon and saves position...
  291.     DDEExecute "ProgMan", "ProgMan", "", "[replaceitem({icon:title})]"
  292.     ' ... Additem can use it
  293.     DDEExecute "ProgMan", "ProgMan", "", "[additem({icon:name},{icon:title},,)]"
  294.     If "{_err}" = "-1"
  295.         OutBox "'{prgname}' icon couldn't be installed in Program Manager."
  296.     EndIf
  297.     ' Brings group window on top, so user can find it immediately.
  298.     DDEExecute "ProgMan", "ProgMan", "", "[showgroup({icon:group},1)]"
  299. EndSub
  300. ' ***************************************************************************************************
  301. Sub "RegBase"
  302.     ' Gets number of elements
  303.     GetTableLineCount "number_reg", "regbasetable"
  304.     If "{number_reg}" > "0"
  305.         Let "i", "1"
  306.         Label "RegBase1"    
  307.         RegBaseWrite "{regbasetable[i;2]}", "{regbasetable[i;3]}"
  308.         RegBaseWrite "{regbasetable[i;3]}", "{regbasetable[i;4]}"
  309.         RegBaseWrite "{regbasetable[i;3]}\shell\open\command", "{targetpath}\{regbasetable[i;5]}"
  310.         If "{regbasetable[i;1]}" <> "CMD"
  311.             RegBaseWrite "{regbasetable[i;3]}\shell\open\ddeexec", "{regbasetable[i;6]}"
  312.             RegBaseWrite "{regbasetable[i;3]}\shell\open\ddeexec\application", "{regbasetable[i;7]}"
  313.             RegBaseWrite "{regbasetable[i;3]}\shell\open\ddeexec\topic", "{regbasetable[i;8]}"
  314.         EndIf
  315.         Compute "i", "{i}" + "1"
  316.         If "{i}" <= "{number_reg}"
  317.             Goto "RegBase1"
  318.         EndIf
  319.     EndIf    
  320. EndSub
  321.  
  322. ' ***************************************************************************************************
  323. Sub "PrgINIs"
  324.     ' Gets number of elements
  325.     GetTableLineCount "number_ini", "initable"
  326.     If "{number_ini}" > "0"
  327.         Let "i","1"
  328.         Label "PrgINIs1"
  329.         INIWrite "{initable[i;1]}","{initable[i;2]}","{initable[i;3]}","{initable[i;4]}"
  330.         Compute "i", "{i}" + "1"
  331.         If "{i}" <= "{number_ini}"
  332.             Goto "PrgINIs1"
  333.         EndIf
  334.     EndIf
  335. EndSub
  336.  
  337. ' ***************************************************************************************************
  338. Sub "ShareExe"
  339.     If "{_locking}" = "0"
  340.         MsgBox "addlocking", "'{prgname}' needs a network or SHARE for his database. Installation program can install SHARE in your AUTOEXEC.BAT and restarts your system after end of installation to let the changes effect. Do you want to add SHARE? To make the changes on yourself choose 'Not install'.", "SHARE.EXE", "&Install;&Not install"
  341.         If "{addlocking}" = "1"
  342.             AddShareExe
  343.         EndIf    
  344.     EndIf
  345. EndSub
  346.  
  347. Sub "PrgEnd"
  348.     Window "-1", "", "Ready!", "It's completed. Installation of '{prgname}' is finished."
  349.     GetUserInput "&OK"
  350.     If "{addlocking}" = "1"
  351.         MsgBox "reboot", "Installation program has add SHARE.EXE to your AUTOEXEC.BAT. To let the changes effect you've to restart your system. Should installation program makes a restart?", "Warmstart", "&Restart;&No Restart"
  352.         If "{reboot}" = "1"
  353.             ReBoot "3"
  354.         Else
  355.             OutBox "Before start of {prgname} you've to restart your system."
  356.         EndIf
  357.     EndIf
  358. EndSub
  359.